package mains;

import cartes.Carte;

import cartes.Denomination;

import mains.RangPoker;
import mains.ReqAnalyseMain;

import rangs.RangCarteSuperieure;
import rangs.RangQuinteRoyale;

public class QuinteRoyale extends AbstractAnalyseurRang{
	public QuinteRoyale() {
		super();
	}

	public boolean reconnaitreMain(ReqAnalyseMain requete) {
		//Juste 1 suite possible... 10-J-Q-K-As
		//As-1-2-3-4 NON VALIDE.
		int count = 0;//00000
		for(Carte c : requete.getMain()){
		  if(c.getDenomination().equals(Denomination.DIX)) 
			count += 1; //00001
		  if(c.getDenomination().equals(Denomination.VALET)) 
			count += 2; //00010
		  if(c.getDenomination().equals(Denomination.DAME)) 
			count += 4; //00100
		  if(c.getDenomination().equals(Denomination.ROI)) 
			count += 8; //01000
		  if(c.getDenomination().equals(Denomination.AS)) 
			count += 16; //10000
		}
		
		if(count == 31 && (hasSameColorNTimes(requete.getMain(), 5) != null)){ //11111
		  RangQuinteRoyale cs = new RangQuinteRoyale();
		  cs.setQuinteRoyale(requete.getMain());
  
		  Main reste = requete.getMain();
		  cs.setReste(new Main()); //Lorsqu'on a une quinte royale, c'est tout ce qui compte!
		  
		  requete.setRangReconnu(cs);
		  return true;
		}
		
		return false; 
	}

	public RangPoker getRang() {
		return RangPoker.QUINTE_ROYALE;
	}
}
